<template>
  <div>
    <el-form-item label="选择按钮">
      <el-checkbox-group v-model="localData.showButtonList">
        <el-checkbox v-for="item in buttonList" :key="item.value" :label="item.label" :value="item.value" />
      </el-checkbox-group>
    </el-form-item>
    <el-form-item label="选择模型">
      <el-select v-model="localData.table" clearable filterable>
        <el-option v-for="opt in tableList" :key="opt.dictValue" :label="`${opt.dictLabel}(${opt.dictValue})`" :value="opt.dictValue" />
      </el-select>
    </el-form-item>
    <el-form-item label="选择流程">
      <el-select v-model="localData.flow" clearable filterable>
        <el-option v-for="opt in modelList" :key="opt.dictValue" :label="`${opt.dictLabel}(${opt.dictValue})`" :value="opt.dictValue" />
      </el-select>
    </el-form-item>
  </div>
</template>

<script>
export default {
  name: 'FlowButtonGroupConfig',
  props: {
    data: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      localData: {},
      buttonList: [
        {
          label: '提交',
          value: 'submit'
        },
        {
          label: '同意',
          value: 'approve'
        },
        {
          label: '驳回',
          value: 'reject'
        },
        {
          label: '撤回',
          value: 'rollback'
        }
      ],
      tableList: [], // 模型接口管理列表
      modelList: [] // 部署管理列表
    };
  },
  watch: {
    data: {
      handler(newVal) {
        if (newVal) {
          this.localData = newVal;
        }
      },
      deep: true,
      immediate: true
    },
    localData: {
      handler(newVal) {
        this.$emit('update:data', newVal);
      },
      deep: true
    }
  },
  mounted() {
    this.searchTable()
    this.searchModel()
  },
  methods: {
    searchTable() {
      this.getDicts('mda_table_info_list').then((response) => {
        this.tableList = response.data;
      });
    },
    searchModel() {
      this.getDicts('code_wf_deployment_list').then((response) => {
        this.modelList = response.data;
      });
    }
  }
};
</script>

<style scoped></style>
